<template>
	<view>
		<web-view :src="url"></web-view>
	</view>
</template>

<script>
	import amap from '../../js_sdk/amap-wx.130.js';
	var _self;
	export default {
		data() {
			return {
				url: '',
				title: '',
				amapPlugin: null,
				gaodekey: '5a96bccf3666231d3e8d55ddd31f8120', //高德key,此处的key需要去高德平台申请获取
			}
		},
		methods: {

		},
		onLoad(option) {
			_self = this;
			//保险页面回调
			//_self.url='https://pay.swiftpass.cn/pay/jspay?showwxtitle=1&token_id=21fd612b26f24ca9267b95cdfd538f2f9';
			// var paramtext = 'id=' + '123456987' + '&phone=' + '18859767532'
			// 	+ '&startStation=' + '南平武夷客运总站' + '&endStation=' + '光泽汽车站';
			// _self.url = 'http://wyzzwx.xmjdt.com/Coach/OtherWxLogin?'+ paramtext;
			//_self.url = 'https://wx.17u.cn/busexternal/?cid=0096&refid=675005066&dep=&des=&depStation=&desStation=&pid=&aid=5096&userOpenid=owP8swK9N08Xjk6BW65PJjQhLLkw#/';
			_self.url = option.url;
			console.log('url',_self.url);
			_self.title = option.name;
			if (_self.title == '公交查询') { 
				var city = "南平市";
				var cityCode = '350700';
				const _self = this;
				this.amapPlugin = new amap.AMapWX({
					key: this.gaodekey
				});
				// 成功获取位置
				_self.amapPlugin.getRegeo({
					success: (data) => {
						if (data[0].regeocodeData.formatted_address) {
							city = `${data[0].regeocodeData.addressComponent.district}`;
							console.log(city, '当前位置');
							if (city.indexOf('武夷山') != -1) {
								cityCode = '350782';3
							}
							if (city.search('建阳') != -1) {
								cityCode = '350784';
							}
							if (city.search('顺昌') != -1) {
								cityCode = '350721';
							}
							if (city.search('建瓯') != -1) {
								cityCode = '350783';
							}
							if (city.search('松溪') != -1) {
								cityCode = '350724';
							}
							if (city.search('政和') != -1) {
								cityCode = '350725';
							}
							if (city.search('光泽') != -1) {
								cityCode = '350723';
							}
							if (city.search('浦城') != -1) {
								cityCode = '350722';
							}
							_self.url = _self.url + '?cCity=' + cityCode;
						}
					},
					fail: (err) => {
						console.log(err);
					}
				});
			}
		},
		onShow() {
			//在onshow做延时操作才可以把导航标题改掉
			setTimeout(function() {
				uni.setNavigationBarTitle({
					title: _self.title
				});
			}, 1000)
		}
	}
</script>

<style>

</style>
